﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using OpenSoftStore.Client.Common;
using OpenSoftStore.Orm.Static;

namespace OpenSoftStore.Client.UIL.ManageSet
{
    public partial class LogicSet : UserControl
    {
        private static LogicSet instance;
        /// <summary>
        /// 返回一个该控件的实例。如果之前该控件已经被创建，直接返回已创建的控件。
        /// 此处采用单键模式对控件实例进行缓存，避免因界面切换重复创建和销毁对象。
        /// </summary>
        public static LogicSet Instance
        {
            get
            {
                if (instance == null)
                {
                    instance = new LogicSet();
                }
                return instance;
            }
        }

        public LogicSet()
        {
            InitializeComponent();
            chkTempMemberPass.Checked = SPAUserConfig.GetValue("TempMemberPass") == "是";
            chkValueRecordSubtractPrice.Checked = SPAUserConfig.GetValue("ValueRecordSubtractPrice") == "是";
        }

        private void chkTempMemberPass_CheckedChanged(object sender, EventArgs e)
        {
            SPAUserConfig.SaveValue("TempMemberPass", chkTempMemberPass.Checked ? "是" : "否");
        }

        private void chkValueRecordSubtractPrice_CheckedChanged(object sender, EventArgs e)
        {
            SPAUserConfig.SaveValue("ValueRecordSubtractPrice", chkValueRecordSubtractPrice.Checked ? "是" : "否");
        }
    }
}
